class RDQuestObject extends RDQuestFramework
	perobjectconfig
	perobjectlocalized
	notplaceable
	abstract;
	
//Quest completed?	
var bool bCompleted;
//Quest currently active? (Can complete quest objectives?)
var bool bActive;
//Notified by owner
var bool bHasBeenNotified;
var bool isOptional;
var bool bAllowCheats;
var bool bFailed;

//Owner system.
var class<RDQuestFramework> OwnerClass;
var RDQuestFramework Owner;

//Localized stuff.
var localized string sName;
var localized string long_description;
var localized string short_description;

////////////////////////////////////////////////
////////////Overides//////////////////////
//////////////////////////////////////////////////

//Has this quest's sub-objective been completed?
function RecieveCompletion(bool isSuccess)
{

}


//////////////////////////////////////////////////////
////////////States////////////////////////////////
/////////////////////////////////////////////////////

//The basic state. Doesen't allow objectives to be failed or completed. The exception is if the player gives up.
auto state Inactive
{
	event Tick()
	{
		if( bActive == true )
			GotoState('Active');
		
	}
	
}

//The active state. This checks to see if the quest/objective is completed.
state Active
{
	event Tick()
	{
		if( bActive == false )
			GotoState('Inactive');
		
		if( RequirementsMet() == true)
			GotoState('Completed');
		else if( bFailed )
			GotoState('Failed');
	}

}

//You have won. Fuck you.
state Completed
{
	event BeginState( name PreviousStateName )
	{
		NotifyCompletion();
	}
	
	function NotifyCompletion()
	{
		GetReward();
		Owner.RecieveCompletion(true);
	}
	
}

//Told you bitch.
state Failed
{
	event BeginState( name PreviousStateName )
	{
		NotifyCompletion();
	}
	
	function NotifyCompletion()
	{
		GetReward();
		Owner.RecieveCompletion(false);
	}
}

////////////////////////////////////////////////////////
///////Input/////////////////////////////////////////
///////////////////////////////////////////////////////
exec function Complete()
{
	ForceComplete();
}

exec function Fail()
{
	ForceFail();
}

///////////////////////////////////////////////////////////////
///////////Local///////////////////////////////////////////
//////////////////////////////////////////////////////////////

//Allows the client to cheat.
function ForceComplete()
{
	if( bAllowCheats )
		GotoState('Completed');
}

//Currently only used by Fail(). It allows him to quit a quest if he so desires.
function ForceFail()
{
	if( isOptional == true )
	{	
		GotoState('Completed');
	}
	else
		GotoState('Failed');
}
	
//////////////////////////////////////////////////
////////////Other functionality////////////
////////////////////////////////////////////////

//Resets the current quest/objective.
function Reset()
{
	GotoState('InActive');
}

//Notify parent of completion.
function NotifyCompletion()
{
	Owner.RecieveCompletion(bCompleted);
}

//Has this Quest/Objective been met?
function bool RequirementsMet()
{
	return bCompleted;
}

//Stub. Meant to be over-ridden. This is for getting rewards that will be recieved on either fail or completion.
function GetReward()
{
	return;
}

defaultproperties
{

}
